<?php

namespace App\Models\Api;

class PartTimeSignUp extends ApiModel
{
    protected $table = 'part_time_sign_up';

    protected $hidden = [
        'com_id', 'part_time_job', 'company_basic', 'part_time_resume'
    ];

    public function part_time_job()
    {
        return $this->hasOne(PartTimeJob::class, 'id', 'pt_job_id')
            ->whereBetween('job_status', [0, 2])
            ->with(['area_city', 'town_city'])
            ->select(['title', 'id']);
    }

    //简历投递的公司
    public function company_basic()
    {
        return $this->hasOne(CompanyBasic::class, 'id', 'com_id')
            ->select(['id', 'company_name']);
    }

    //企业用来查看投递简历
    public function part_time_resume()
    {
        return $this->hasOne(PartTimeResume::class, 'id', 'pt_resume_id')
            ->with(['area_address', 'town_address'])
            ->select([
                'id', 'name', 'sex', 'birthday', 'education',
                'intention', 'address'
            ]);
    }

    public function getTimeAttribute()
    {
        return substr($this->attributes['updated_at'], 0, 10);
    }
}
